/**
  ETFAna project, Anyang Normal University && IMP-CAS
  \class ETFGanaPre
  \brief The ana part of the offline ana GUI system
  \author SUN Yazhou, asia.rabbit@163.com
  \since 2024-05-12
  \date 2024-05-12 last modified
  \attention
  changelog
  <table>
  <tr>  <th>Date         <th>Author      <th>Description                   </tr>
  <tr>  <td>2024-05-12   <td>Asia Sun    <td>file created                  </tr>
  </table>

  \copyright Copyright (c) 2021-2024 Anyang Normal U. && IMP-CAS with LGPLv3 LICENSE
*/

#ifndef ETFGanaPre_h
#define ETFGanaPre_h

#include <string>
#include <pthread.h>
#include <TGFrame.h>

using std::string;

class TGLabel;
class TGTextEntry;
class TGTextButton;
class TGCheckButton;
class TGHProgressBar;

class ETFRun;
class ETFGana;
class ETFAnalyzer;
class ETFPIDManager;
class ETFParaManager;
class ETFTrackManager;
class ETFSource;

class ETFGanaPre : public TGCompositeFrame{
public:
	ETFGanaPre(ETFGana *p, int w = 1000, int h = 625);
	virtual ~ETFGanaPre();

  virtual void Initialize(); ///< creaet all the graphical objects

  virtual void AddRawDataFile();
  virtual void StartAna();
  int AnaStatus() const{ return fAnaSta; }
  void ana(); // the etfana routine
  virtual void Update(); ///< update ana results
  virtual void Disable(); ///< disable all till the ana completed
  TGHProgressBar *AnaProgressBar() const{ return fPrgBar; }

	ClassDefOverride(ETFGanaPre, 0);

protected:
  unsigned fWidth, fHeight;
  TGTextButton *fStartAnaBtn, *fAddfBtn;
  TGTextEntry *fEntryEv0, *fEntryEv1;
  TGCheckButton *fC2DTrk, *fC3DTrk, *fCPID;
  TGHProgressBar *fPrgBar;
  TGLabel *fDataFileLabel, *fNofTrkL[5][4], *fEvAnedLabel;
  int fCnt[5][4]; // for accumulation to fNofTrkL

  int fAnaSta; ///< 0: not anaed, 1: ana-ing; 2: has anaed
  unsigned long fFile0Size; ///< file size in MB of the first raw data file
  pthread_t fAnaRun;
  ETFGana *fGana; ///< the mother Gana frame
  int fAnaLevel; ///< ana level of fAnaTask
  unsigned fNofEv; ///< # of events to be analyzed

  ETFRun *fRun;
  ETFParaManager *fpm;
  ETFTrackManager *ftm;
  ETFPIDManager *fpidm;
  ETFSource *fSrc;
};

#endif
